package com.amit.struts;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class LocaleAction extends Action {
	
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		
		String L=request.getParameter("language");
		System.out.println(L);
		Locale loc=new Locale(L);
		
		HttpSession session=request.getSession();
		
		Locale lo=(Locale) session.getAttribute(Action.LOCALE_KEY);
		
		System.out.println("current locale is"+lo.getLanguage());
		session.setAttribute(Action.LOCALE_KEY, loc);
		System.out.println("locale is changed to"+L);
		
		return mapping.findForward("search");
	}
	

}
